package com.ruoyi.location.service;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.location.controller.vo.QuickReportVo;
import com.ruoyi.location.repository.QuickReportRepository;
import com.ruoyi.location.repository.generator.entity.QuickReportLocation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class QuickReportService {
    @Autowired
    private QuickReportRepository quickReportRepository;

    public int insertQuickReportLocation(QuickReportVo quickReportVo) {
        if (quickReportVo == null || StringUtils.isBlank(quickReportVo.getRoom())) {
            return -1;
        }
        int result = 0;
        String[] rooms = quickReportVo.getRoom().split(",");
        for (String room : rooms) {
            if (StringUtils.isBlank(room)) {
                continue;
            }
            QuickReportLocation qrLocation = new QuickReportLocation();
            qrLocation.setRoom(room);
            qrLocation.setName(quickReportVo.getName());
            qrLocation.setLongitude(quickReportVo.getLongitude());
            qrLocation.setLatitude(quickReportVo.getLatitude());
            quickReportRepository.insertQuickReportLocation(qrLocation);
        }
        return 1;
    }

}